package com.gdust.lease.web.admin.controller.apartment;


import com.gdust.lease.common.result.Result;
import com.gdust.lease.web.admin.service.FileService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * 文件上传接口
 */
@Tag(name = "文件管理")
@RequestMapping("/admin/file")
@RestController
public class FileUploadController {
    //注入文件类的service
    @Autowired
    private FileService fileService;

    /**
     * 上传图片接口
     * @param file 上传文件
     * @return
     */
    @Operation(summary = "上传文件")
    @PostMapping("upload")
    public Result<String> upload(@RequestParam MultipartFile file) {
        //1.获取上传的文件
        //2.调用service的方法上传，返回COS路径
        String url = fileService.upload(file);
        return Result.ok();
    }

}
